import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
import path from 'node:path';

export default defineConfig({
  plugins: [solidPlugin()],
  build: {
    target: 'esnext',
    outDir: path.resolve(__dirname, './dist'),
    lib: {
        entry: path.resolve(__dirname, './src/index.tsx'),
        name: 'cui-virtuallist'
    },
    polyfillDynamicImport: false,
    rollupOptions: {
      context: 'globalThis',
      preserveEntrySignatures: 'strict',
      external: ['solid-js'],
      output: [
          {
              format: 'es',
              exports: 'named',
              sourcemap: false,
              entryFileNames: 'cui-virtuallist.min.esm.js',
              chunkFileNames: '[name].js',
              assetFileNames: '[name].[ext]',
              namespaceToStringTag: true,
              inlineDynamicImports: false,
              manualChunks: undefined,
          }
      ]
    }
  },
  resolve: {
    conditions: ['development', 'browser'],
    alias: {
    }
  },
  server: {
    port: 5000,
    host: '0.0.0.0',
  },
  base: './'
});
